package text_based_graphic_adventure;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class GUIFrame extends JFrame implements ActionListener, ChangeListener, ItemListener, MouseListener {

    JToggleButton jtb;
    JTextArea jta;
    
    //ROOMS
    public void initRooms()
    {
        //Room(String d, String n, Room er, Room wr, Room nr, Room sr) {
        Room startRoom = new Room ("You are alone in a room there is a lamp, a carpet, a door, a desk, and a chair","Starting Study", null, null, null, hallway);
        Room hallway = new Room ("You are now in a large hallway filled with torches", "Torchlit Hallway", fluffyPillowRoom, null, null, waterStaircaseRoom);
        Room waterStaircaseRoom = new Room ("You enter a large room with two doors a staircase going underwater and a desk in the middle", "Water Staircase Room", dankRoom, skylightRoom, hallway1, whiteElevatorRoom);
        Room fluffyPillowRoom = new Room ("You open the door only to reveal a.... FLUFFY PILLOWS", "FLUFFY PILLOWS", null, hallway1, null, null);
        Room dankRoom = new Room ("You decide to take the door the right and it leads to a small dark room with the slight sound of water plinking ofton", "Dank Room", null, waterStaircaseRoom, skylightRoom, center);
        Room skylightRoom = new Room ("You step into a room with a large skylight glance around and spot multiple doors.", "Skylight room", waterStaircaseRoom, center, mountainOfPillows, dankRoom);
        Room whiteRoom = new Room ("You are in a white room with an elevator and elevator music", "It's white", spikePit, null, null, mountainOfPillows);
        Room mountainOfPillows = new Room ("THE SPANISH INQUISISTION, ITS UNEXPECTED", "Ummmmmm what", null, null, null, null);
        Room center = new Room ("You finally drag yourself out of the BS and begin crawling your way to a sign that says EXIT you open it and enter a room with 4 doors", "THE CENTER",rainbowRoad , partyWin, rubberSnakePit, fourtyTwoLose); 
        Room partyWin = new Room ("You decide to go through door 17 and am suddenly surrounded by party streamers a man walks up to you asking you how it was and if it was fun? You gawk at him as he tells you that was a party game that you CHOOSE to do for entertainment, you punch him in that face and leave", null, null. null, null, null);
        Room rainbowRoad = new Room ("You decide to go through door 27 and it leads to a rainbow bridge covered in car wrecks... whatever there are two doors left or right", "This is for you Hannah", RubberSnakePit, rainbowRoadLose, null, bottomlessPitLose);
        Room rubberSnakePit = new Room ("You enter the room and see a huge pit full of snakes and a highline, being a cocky person you step on it and immeadiatly fall into it to discover that.... THE SNAKES ARE RUBBER of also some huge oak doors", "Snake pit of LOL's", bottomlessPitLose, rainbowRoad, inceptionWin, kirbyWin);
        Room fourtyTwoLose = new Room ("You walk in a massive screen flases 42 repeatedly and tells you the secret to life which then breaks your mind and you die", "LOLOLOLOL", null, null, null, null);
        Room rainbowRoadLose = new Room ("Oh look you fell off rainbow road why am I not suprised", "I <3 you Hannah but UBAD", null, null, null, null);
        Room inceptionWin = new Room ("You creak open a door only to get a shotgun shell to the face but, you lived through this you are just in you bed... INCEPTION", "INCEPTION", null, null, null, null);
        Room bottomlessPitLose = new Room ("You enter a cylindirical room and suddenly the floor drops out and you now are in a infinte falling loop, on the brightside there is a tv and magic buffet so you just watch tv, eat, and skydive till you die :P", "I guess thats good", null, null, null, null);
                
                }

    GUIFrame() {
        //Buttons and other stuff to make it easier
        
        jtb = new JToggleButton("Door One");
        jtb = new JToggleButton("Door Two");
        jta = new JTextArea();
        jta.setEditable(false);
        jta.setLineWrap(true);
        jta.setWrapStyleWord(true);
        jtb.addItemListener(this);
        
        //Panel setup
        JPanel centerPanel = new JPanel();
        JPanel westPanel = new JPanel();
        JPanel eastPanel = new JPanel();
        JPanel southPanel = new JPanel();
        JPanel northPanel = new JPanel();
        
        
        //A SHIT TON OF BUTTONS
        JButton doorOneButton = new JButton("Open Door");
        JButton doorTwoButton = new JButton("Check Carpet");
        JButton chairCheck = new JButton("Check Chair");
        JButton lampCheck = new JButton("Check Lamp");
        JButton testButton = new JButton("POINTLESS");
        doorOneButton.addActionListener(this);
        doorTwoButton.addActionListener(this);
        chairCheck.addActionListener(this);
        lampCheck.addActionListener(this);

        
        //SETTING LAYOUT UP
        northPanel.setLayout(new BorderLayout());
        centerPanel.setLayout(new BorderLayout());
        southPanel.setLayout(new BorderLayout());
        eastPanel.setLayout(new BorderLayout());
        westPanel.setLayout(new BorderLayout());
        this.setLayout(new BorderLayout());

        
        //OPERATIONS AND STUFF
        jta.setEditable(false);
        doorOneButton.addActionListener(this);
        eastPanel.add(doorOneButton);
        westPanel.add(doorTwoButton);
        northPanel.add(lampCheck);
        southPanel.add(chairCheck);
        centerPanel.add(jta);
        add(northPanel, BorderLayout.NORTH);
        add(centerPanel, BorderLayout.CENTER);
        add(westPanel, BorderLayout.WEST);
        add(southPanel, BorderLayout.SOUTH);
        add(eastPanel, BorderLayout.EAST);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //closes on program whenyou hit X
        this.setSize(500, 500); //have before visible
        this.setVisible(true);

        jta.setText("You are alone in a room there is a lamp, a carpet, a door, a desk, and a chair");



    }

    
    //Action Listener
    @Override
    public void actionPerformed(ActionEvent ae) {
        if (ae.getActionCommand().equals("Check Lamp")) {
            jta.setText("The lamp is bolted down");
        }
        if (ae.getActionCommand().equals("Check Chair")) {
            jta.setText("There was nothing under the chair or in the coushins");
        }
        if (ae.getActionCommand().equals("Open Door")) {
            jta.setText("Behind the door is a brick wall, hmmm.");
        }
        if (ae.getActionCommand().equals("Check Carpet")){   
            jta.setText("There is a trap door beneath it do you wish to enter");
        }
    }

    @Override
    public void stateChanged(ChangeEvent ce) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void itemStateChanged(ItemEvent ie) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseClicked(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mousePressed(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseReleased(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseEntered(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mouseExited(MouseEvent me) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
